<?php
	class Page{

		private $file;
		private $path;

		/**
		@class 	Page
		
		@params 	string 	file 	Nom du fichier 	NULL
		Permet d'inclure les page de façon sécurisé
		*/
		function __construct($file=NULL){
			/* Existance du paramètre //*/
			if(!isset($file)){
				$this->getGET();
			}else{
				$this->file = $file;
			}

			$this->pageExist();
			$this->pInclude();
		}

		/**
		@function pageExist

		Vérifie si la page existe
		*/
		function pageExist(){
			$path = Config::$pathPage.$this->file.'.php';
			if(!file_exists($path)){
				$this->path = Config::$pathPage.Config::$errorPage.'.php';
			}else{
				$this->path = $path;
			}
		}

		/**
		@function pInclude

		Inclus la page en question
		*/
		function pInclude(){
			if(Config::$debugPage)
				eden('debug')->output("Page: include ".$this->path);
			include($this->path);
		}

		/**
		@function getGET

		Recupere la page en GET
		*/
		function getGET(){
			if(isset($_GET[Config::$varPage])){
				$this->file = htmlentities($_GET[Config::$varPage]);
			}else{
				$this->file = Config::$defaultPage;
			}
		}
	}
?>